<?php
/**
 * Created by PhpStorm.
 * User: Min
 * Date: 2018/5/23
 * Time: 14:25
 */

namespace SDXApi\Service;


use SDXApi\Abstracts\TemplateAbstract;

class HomeTemplateImageBackgroundService extends TemplateAbstract
{

    /**
     * @var HomeTemplateStencilImageModel
     */
    protected $templateStencilImageModel;

    /**
     * HomeTemplateImageService constructor.
     */
    public function __construct()
    {
        //$this->templateStencilImageModel = new HomeTemplateStencilImageModel();
    }

    /**
     * 处理图片模块
     * @param array $stencil
     * @param int $userId
     * @param int $wid
     * @return array
     */
    public function handle($stencil = array(), $userId = 0, $wid = 8)
    {
        $images = $this->get_image_background_list($stencil['id']);

        $stencil['images_list'] = $this->get_image_background_son($images['id']);
        $stencil['size_message'] = '710px 340px';
        $stencil['background_size'] = '750px 360px';
        $stencil['url'] = $images['url'];

        return $stencil;
    }

    protected function get_image_background_list($stencil_id)
    {
        $where = array(
            'stencil_id' => $stencil_id
        );

        return M('home_template_stencil_image_background')->where($where)->find();
    }

    protected function get_image_background_son($background_id)
    {
        $where = array(
            'background_id' => $background_id
        );

        return M('home_template_stencil_image_background_son')->where($where)->select();
    }

}